//
//  LiveShowViewController.swift
//  VideoPhotoCapture
//
//  Created by 杨伟诺 on 2020/9/27.
//

import UIKit
import AVFoundation
import SnapKit



class LiveShowViewController: UIViewController {
    
    fileprivate var liveCapture: LiveShowVideoCapture = LiveShowVideoCapture.liveShowmanager
    
//    fileprivate var videoEncoder: VideoEncoder!
//    fileprivate var videoDecoder: VideoDecoder!
    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(liveCapture.liveView)
        liveCapture.authorization()
        liveCapture.configurationLiveSession()
        liveCapture.delegate = self
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        liveCapture.liveView.frame = CGRect.init(x: 0, y: 0, width: view.frame.width, height: view.frame.height * 0.35)
        liveCapture.liveLayer.frame.size = CGSize.init(width: view.frame.width, height: view.frame.height * 0.35)
    }
    
    @objc fileprivate func startCapture(){
    }
    
    private func setVideoConfig(){
        let videoC = VideoConfig()
        videoC.width = liveCapture.width
        videoC.height = liveCapture.height
        videoC.bitrate = videoC.height * videoC.width * 5
        
//        videoEncoder = VideoEncoder.init(config: videoC)
//        videoEncoder.delegate = self
//
//        videoDecoder = VideoDecoder.init(config: videoC)
//        videoDecoder.delegate = self
        
        
    }
}


extension LiveShowViewController: LiveShowVideoCaptureDelegate{
    
    func captureSampleBuffer(_ buffer: CMSampleBuffer, type: String) {
        
        guard liveCapture.isStartRunning else {return}
        
        if type == LiveShowVideoCaptureType.audio.rawValue{
            
        }
        else
        {
            
        }
    }
}

 
//extension LiveShowViewController: VideoEncoderDelegate{
//
//    func videoEncodeCallbackWith(h264Data: Data) {
//
//    }
//
//    func videoEncodeCallbackWith(sps: Data, pps: Data) {
//
//    }
//}
//
//extension LiveShowViewController: VideoDecoderDelegate{
//    func videoDecodeCallbackWith(imageBuffer: CVPixelBuffer) {
//
//    }
//
//
//
//}
